<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       async function fetchData(url) {
            try {
                const response = await fetch(url);
                const data = await response.text();  // 解析响应体为文本

                // 使用正则表达式移除 createHeroList 包裹的函数调用
                const jsonData = data.replace(/^[a-zA-Z]+/, '').replace(/^\(/, '').replace(/\)$/, '');

                // 解析成 JavaScript 对象
                const parsedData = JSON.parse(jsonData);

                // 过滤所需的数据
                const filteredObj = parsedData.data.map(item => ({
                    title: item.title,
                    occupation: item.occupation,
                    heroImg: item.heroimg
                }));
                const res = {
                    data: filteredObj.slice(1)
                }
                return res  // 返回处理后的数据
            } catch (error) {
                console.error('请求出错:', error);
                return []  // 返回一个空数组，表示请求失败
            }
        }
        fetchData ('https://pvp.qq.com/webplat/info/news_version3/15592/18024/23901/24397/24398/m17330/list_1.shtml?callback=createHeroList')
        .then (filteredObj =>  {
            console.log ('过滤后的函数:',filteredObj);
        })
    </script>
</body>
</html>